package com.vkmessenger.net.clients;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HttpContext;

/**
 * Created with IntelliJ IDEA.
 * User: Evgeniy Krasko
 * Date: 20.06.12
 * Time: 17:33
 */
public class HttpClientFactory {
    public static HttpClient getTunedHttpClient() {
        DefaultHttpClient client = new DefaultHttpClient();
        client.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy(){
            @Override
            public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
                long  keepAlive = super.getKeepAliveDuration(response, context);
                if (keepAlive == -1) keepAlive = 10000;
                return keepAlive;
            }
        });
        return client;
    }
}
